//alert('loaded');
self.postMessage('the data');
self.onmessage=function (event) {
	alert(event.data);
	url = event.data.url;
	postdata = event.data.postdata;
	alert('in worker');
	$.ajax({
		url:url,
		data:postdata,
		async:true,
		timeout:3000,
		type:"POST",
		success:function(data){
			outdecode = jQuery.parseJSON(data);
			$(".searchcontainer").children().remove();
			//items = jQuery.parseJSON(outdecode.data);
			items = outdecode.data;
			nbpage = outdecode.nbpage;
			for(var i=0;i<items.length;i++) {
				var tr = $("<tr></tr>");
				tr.append($("<td></td>").append(items[i].User));
				tr.append($("<td></td>").append(items[i].title));
				tr.append($("<td></td>").append(items[i].payment));
				tr.append($("<td></td>").append(items[i].Created));
				var td = $("<td></td>");
				
				td.append($('<a href="/default/training/show/id/'+items[i].id+'">detail</a>'));
				if(items[i].editabled)
					td.append($('<a href="/default/training/edit/id/'+items[i].id+'">edit</a>'));
			
				tr.append(td);
				$(".searchcontainer").append(tr);
			}
			waitdiv.hide();
			if(nbpage>"1") {
				$(".searchcontainer + tfoot").children().remove();
				tr = $("<tr></tr>");
				td = $("<td></td>");
				td.attr("colspan",2);
				td.css("text-align","center");
				td.append("Pages : ");
				for(var i =0 ;i<nbpage;i++) {
					a = $('<a href="#"></a>');
					a.addClass('paging');
					if(i=0)
						a.addClass('pageselected');
					a.append((i+1));
					td.append(a);
				}
				tr.append(td);
				$(".searchcontainer + tfoot").append(tr);
				$(".paging").click(pageclick);
			}
			else{$(".searchcontainer + tfoot").children().remove();}
		}
	});
};